<template>
  <view class="container">
    <view class="content">
      <view class="section">
        <text class="label">预约服务：</text>
        <view class="service-status">
          <text class="value">防水补漏</text>
          <view class="status">待接单</view>
        </view>
      </view>
      <view class="section">
        <text class="label">预约时间：</text>
        <text class="value">2023-02-15 09:00</text>
      </view>
      <view class="section">
        <text class="label">服务地址：</text>
        <text class="value">永安道49号安德公寓1-302</text>
      </view>
      <view class="section">
        <text class="label">备注信息：</text>
        <text class="value">水暖井管道漏水严重</text>
      </view>
      <view class="cancel-card">
        <text class="label">请填写取消原因</text>
        <input type="text" v-model="cancelReason" placeholder="请输入" />
      </view>
      <button class="submit-btn" @click="showModal">提交</button>
    </view>

    <!-- 模态框 -->
    <view class="modal" v-if="isModalVisible">
      <view class="modal-content">
        <text class="modal-title">是否取消预约？</text><br>
        <text class="modal-warning">取消预约后订单无法恢复，若有需要请您重新申请！</text>
        <view class="modal-buttons">
          <button @click="hideModal">取消</button>
          <button @click="goToModifyPage">确认</button>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      cancelReason: '',
      isModalVisible: false
    };
  },
  methods: {
    showModal() {
      if (this.cancelReason) {
        this.isModalVisible = true;
      } else {
        uni.showToast({
          title: '请输入取消原因',
          icon: 'none'
        });
      }
    },
    hideModal() {
      this.isModalVisible = false;
    },
	
    //跳转到修改预约页面
    goToModifyPage(){
    	uni.navigateTo({
    		url:'/pages/index/order/ModifyPage'
    	});
    },
  }
};
</script>

<style>
.container {
  padding: 20px;
  background-color: #fff;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.content {
  background-color: #fff;
  padding: 20px;
  height: 100vh;
  border-radius: 10px;
}

.section {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
}

.label {
  font-size: 16px;
  color: #333;
  margin-right: 10px;
}

.service-status {
  display: flex;
  align-items: center;
}

.service-status {
  display: flex;
  align-items: center;
}

.value {
  font-size: 16px;
  color: #666;
  margin-right: 10px;
}

.status {
  background-color: #e0f7ff;
  color: #007bff;
  border-radius: 15px;
  padding: 5px 10px;
  font-size: 14px;
}

.cancel-card {
  background-color: #f9f9f9;
  padding: 15px;
  border-radius: 10px;
  margin-top: 20px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  margin-top: 10px;
}

.submit-btn {
  width: 80%;
  background-color: #007bff;
  color: #fff;
  padding: 10px;
  text-align: center;
  border: none;
  border-radius: 5px;
  margin: 20px auto 0;
  display: block;
}

/* 模态框样式 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background-color: #fff;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  width: 80%;
  max-width: 300px;
}

.modal-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 10px;
}

.modal-warning {
  color: red;
  font-size: 14px;
  margin-bottom: 20px;
}

.modal-buttons {
  display: flex;
  justify-content: space-around;
}

.modal-buttons button {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  background-color: #007bff;
  color: #fff;
  cursor: pointer;
}

.modal-buttons button:first-child {
  background-color: #ccc;
}
</style>